Learn R Programming

oce (version 1.8-1)

[[,amsr-method: Extract Something From an amsr Object

Description

Generally, the [[ method lets users extract information from oce objects, without having to know the details of the internal storage. For many oce sub-classes, [[ can also return quantities that are computed from the object's contents.

Usage

# S4 method for amsr
[[(x, i, j, ...)

Value

In all cases, the returned value is a matrix with with NA values inserted at locations where the raw data equal as.raw(251:255), as explained in “Details”.

Arguments

x

an amsr object.

i

character value indicating the name of an item to extract.

j

optional additional information on the i item.

...

ignored.

Details of the Specialized Method

If i is "?", then the return value is a list containing four items, each of which is a character vector holding the names of things that can be accessed with [[. The data and metadata items hold the names of entries in the object's data and metadata slots, respectively. The dataDerived and metadataDerived items are each NULL, because no derived values are defined by cm objects.

Data within the data slot may be found directly, e.g. i="SSTDay" will yield sea-surface temperature in the daytime satellite, and i="SSTNight" is used to access the nighttime data. In addition, i="SST" yields a computed average of the night and day values (using just one of these, if the other is missing). This scheme of providing computed averages works for all the data stored in amsr objects, namely: time, SST, LFwind, MFwind, vapor, cloud and rain. In each case, the default is to calculate values in scientific units, unless j="raw", in which case the raw data are returned.

The conversion from raw to scientific units is done with formulae found at http://www.remss.com/missions/amsre, e.g. SST is computed by converting the raw value to an integer (between 0 and 255), multiplying by 0.15C, and subtracting 3C.

The "raw" mode can be useful in decoding the various types of missing value that are used by amsr data, namely as.raw(255) for land, as.raw(254) for a missing observation, as.raw(253) for a bad observation, as.raw(252) for sea ice, or as.raw(251) for missing SST due to rain or missing water vapour due to heavy rain. Note that something special has to be done for e.g. d[["SST","raw"]] because the idea is that this syntax (as opposed to specifying "SSTDay") is a request to try to find good data by looking at both the Day and Night measurements. The scheme employed is quite detailed. Denote by "A" the raw value of the desired field in the daytime pass, and by "B" the corresponding value in the nighttime pass. If either A or B is 255, the code for land, then the result will be 255. If A is 254 (i.e. there is no observation), then B is returned, and the reverse holds also. Similarly, if either A or B equals 253 (bad observation), then the other is returned. The same is done for code 252 (ice) and code 251 (rain).

Details of the General Method

Note: the text of this section is identical for all oce subclasses, and so some of what you read here may not be relevant to the class being described in this help page.

If the specialized method produces no matches, the following generalized method is applied. As with the specialized method, the procedure hinges first on the values of i and, optionally, j. The work proceeds in steps, by testing a sequence of possible conditions in sequence.

  1. A check is made as to whether i names one of the standard oce slots. If so, [[ returns the slot contents of that slot. Thus, x[["metadata"]] will retrieve the metadata slot, while x[["data"]] and x[["processingLog"]] return those slots.

  2. If i is a string ending in the "Unit", then the characters preceding that string are taken to be the name of an item in the data object, and a list containing the unit is returned (or NULL if there is no such unit). This list consists of an item named unit, which is an expression(), and an item named scale, which is a string describing the measurement scale. If the string ends in " unit", e.g. x[["temperature unit"]] (note the space), then just the expression is returned, and if it ends in " scale", then just the scale is returned.

  3. If i is a string ending in "Flag", then the corresponding data-quality flag is returned (or NULL if there is no such flag).

  4. If the object holds hydrographic information (pressure, salinity, temperature, longitude and latitude) then another set of possibilities arises. If i is "sigmaTheta", then the value of swSigmaTheta() is called with x as the sole argument, and the results are returned. Similarly, swSigma0() is used if i="sigma0", and swSpice() is used if i="spice". Of course, these actions only make sense for objects that contain the relevant items within their data slot.

  5. After these possibilities are eliminated, the action depends on whether j has been provided. If j is not provided, or is the string "", then i is sought in the metadata slot, and then in the data slot, returning whichever is found first. In other words, if j is not provided, the metadata slot takes preference over the data slot. However, if j is provided, then it must be either the string "metadata" or "data", and it directs where to look.

  6. If none of the above-listed conditions holds, then NULL is returned.

Author

Dan Kelley

Details

A two-step process is used to try to find the requested information. First, a class-specific function is used (see “Details of the Specialized Method”). If this yields nothing, then a general method is used (see “Details of the General Method”). If both methods fail, then [[ returns NULL.

Some understanding of the subclass is required to know what can be retrieved with [[. When dealing with an unfamiliar subclass, it can be useful to first use x[["?"]] to get a listing of the retrievable items. See “Details of the Specialized Method” for more information.

See Also

Other functions that extract parts of oce objects: [[,adp-method, [[,adv-method, [[,argo-method, [[,bremen-method, [[,cm-method, [[,coastline-method, [[,ctd-method, [[,echosounder-method, [[,g1sst-method, [[,gps-method, [[,ladp-method, [[,landsat-method, [[,lisst-method, [[,lobo-method, [[,met-method, [[,oce-method, [[,odf-method, [[,rsk-method, [[,sealevel-method, [[,section-method, [[,tidem-method, [[,topo-method, [[,windrose-method, [[,xbt-method, [[<-,adv-method

Other things related to amsr data: [[<-,amsr-method, amsr-class, amsr, composite,amsr-method, download.amsr(), plot,amsr-method, read.amsr(), subset,amsr-method, summary,amsr-method

Examples

Run this code
# Histogram of SST values
library(oce)
data(amsr)
hist(amsr[["SST"]])

Run the code above in your browser using DataLab